<template>
    <div id="table">
        <el-table
                border
                :data="businessmanCheckTable" >
            <el-table-column
                    fixed
                    prop="id"
                    label="id"
                    align="center"
                    font-size="8"
            >
            </el-table-column>
            <el-table-column
                    fixed
                    prop="restaurantname"
                    label="名称"
                    align="center"
                    font-size="8"
            >
            </el-table-column>
            <el-table-column
                    fixed
                    prop="url"
                    label="餐厅图片"
                    align="center"
                    font-size="8"
            >
                <template slot-scope="scope">
                    <img :src="scope.row.url" style="width: 100px;height: 100px"/>
                </template>
            </el-table-column>
            <el-table-column
                    fixed
                    prop="remark"
                    label="餐厅描述"
                    align="center"
                    font-size="8"
            >
            </el-table-column>
            <el-table-column
                    prop="address"
                    label="地址"
                    align="center"
                    font-size="8"
            >
            </el-table-column>
            <el-table-column
                    prop="phone"
                    label="电话"
                    align="center"
                    font-size="8"
            >
            </el-table-column>
            <el-table-column
                    fixed
                    prop="userid"
                    label="店长id"
                    align="center"
                    font-size="8"
            >
            </el-table-column>
            <el-table-column
                    fixed
                    prop="state"
                    label="审核状态"
                    align="center"
                    font-size="8"
            >
                <template slot-scope="scope">
                    <el-tag size="medium" :type="scope.row.state==0?'success':'danger'">
                        {{ scope.row.state==0?"待审核":"已审核"}}
                    </el-tag>
                </template>
            </el-table-column>
            <el-table-column
                    align="center"
                    fixed="right"
                    label="操作"
                    width="300px"
            >
                <template slot-scope="scope">
                    <el-button icon="el-icon-edit" type="primary" size="mini" @click="pass(scope.row)"  round>审核通过</el-button>
                    <el-button icon="el-icon-delete" type="warning" size="mini" @click="rebut(scope.row)" round>审核驳回</el-button>
                </template>
            </el-table-column>
        </el-table>
    </div>
</template>

<script>
    export default {
        name: "BusinessmanCheck",
        data(){
            return{
                businessmanCheckTable:[],
            }
        },
        created() {
            this.searchBusinessman();
        },
        methods:{
            //审核驳回
            rebut(row){
                this.$http.post("/businessman/businessman/rebut",row).then(result=>{
                    if (result.data.code===2000){
                        this.searchBusinessman();
                        this.$message.success(result.data.msg);
                    }else if (result.data.code===5000){
                        this.$message.success(result.data.msg);
                    }
                })
            },
            //审核通过
            pass(row){
                this.$http.post("/businessman/businessman/pass",row).then(result=>{
                    if (result.data.code===2000){
                        this.searchBusinessman();
                        this.$message.success(result.data.msg);
                    }else if (result.data.code===5000){
                        this.$message.success(result.data.msg);
                    }
                })
            },
            //初始化商家入驻信息的表格
            searchBusinessman(){
                this.$http.post("/businessman/businessman/selectByState").then(result=>{
                    if (result.data.code===2000){
                        //console.log(result.data.data)
                        this.businessmanCheckTable=result.data.data;
                    }
                })
            }
        }
    }
</script>

<style scoped>

</style>